<template>
	<view class="psychologicalTest">
		<web-view src="https://www.betterself.com.cn/h5/"></web-view>
		<!-- <view class="headBox">
			<view>
				<view class="tit">{{topImgList.title}}</view>
				<view>{{topImgList.content}}</view>
			</view>
			<view>
				<image :src="topImgList.pic" mode=""></image>
			</view>
		</view>
		<view class="contentBox">
			<view class="card" v-for="(item,i) in list" :key="i">
				<view class="topBox" @click.stop="onSkip(item)">
					<view class="left">
						<view>{{item.paperName}}<text>Psychological test</text></view>
						<view class="photoBox">
							<image class="photoIcon" v-for="(img,idx) in item.joinerList" :key="idx" :src="img"></image>
							<text class="num">已有{{item.joinerNum}}人参与</text>
						</view>
					</view>
					<view class="btn" v-if="!item.isDone"  @click.stop="$to(`/pages/index/test/test?id=${item.id}&&pagetype=心理测试`)">立即测试
					</view>
				</view>
				<view class="bottomBox">{{item.paperIntroduction}}</view>
			</view>
			<view style="margin-top: 200rpx;">
				<view style="text-align: center;" v-if="list.length==0">
					<image style="width: 200rpx;height: 200rpx;" src="../../../static/nodata.png"></image>
					<view style="color: #999;text-align: center;">暂无数据</view>
				</view>
				<view style="text-align: center;color: #999;font-size: 24rpx;" v-if="noMoreData&&list.length!=0">
					没有更多啦
				</view>
			</view>

		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				topMsg:{},
				topImgList:[],
				page: 1,
				lastPage: 1,
				noMoreData: false,
				list: []
			}
		},
		onReachBottom() {
			if (this.page < this.lastPage) {
				this.page += 1
				this.getPsychologicalTest()
			} else {
				this.noMoreData = true
			}
		},
		onShow() {
			// this.getTopImg()
			// this.getPsychologicalTest()
		},
		methods: {
			async getTopImg() {
				// 0首页 1研学 2冬夏令营 3红领巾 4托管 5心理测评
				const res = await this.$api.get(`image/get/5`, {});
				console.log(res, "心理")
				if (res.code == 200) {
					this.topMsg = res.data
					// this.topImgList = res.data.image.split(',')
					this.topImgList = res.data.bastBanner[0]
				}
			},
			onSkip(item) {
				if (item.isDone) {
					this.$to(`/pages/index/evaluationResult?id=${item.id}&pagetype=心理测试&joinPaperId=${item.joinPaperId}`)
				}
			},
			async getPsychologicalTest() {
				const res = await this.$api.get('paper/psychology/list', {
					page: this.page,
					limit: 10,
					type: 1, //0-党建学习 1-心理测评
				});
				// console.log(res, "11111--")
				if (res.code == 200) {
					const {
						list,
						totalPage
					} = res.data
					if (this.page == 1) {
						this.list = list || [];
						this.lastPage = totalPage || 1;
						// console.log(this.list, 'this.list')
					} else {
						this.list.push(...list);
					}
					this.page != 1 && list.length == 0 ? this.noMoreData = true : this.noMoreData = false
				}

			},
		}
	}
</script>

<style>
	page {
		background: #F7F7F7;
	}
</style>
<style lang="scss" scoped>
	.contentBox {
		margin: -80rpx 20rpx 0;
		position: relative;
		z-index: 2;


		.card {
			background: #fff;
			margin-bottom: 20rpx;
			border-radius: 20rpx;
			padding: 26rpx 24rpx;
			font-size: 24rpx;
			font-weight: 500;
			color: #333333;
			line-height: 38rpx;

			.bottomBox {
				border-top: 1px solid #F0F0F0;
				padding: 20rpx 0 0;
			}

			.topBox {
				position: relative;

				.left {
					font-size: 32rpx;
					font-weight: bold;
					color: #333333;

					.photoBox {
						display: flex;
						margin: 34rpx 0 37rpx 10rpx;
					}

					.photoIcon {
						width: 46rpx;
						height: 46rpx;
						border-radius: 50%;
						margin-left: -10rpx;
					}

					.num {
						font-size: 24rpx;
						font-weight: 500;
						color: #999999;
					}

					text {
						margin-left: 10rpx;
						font-size: 24rpx;
						font-weight: 500;
						color: #999999;
					}
				}

				.btn {
					position: absolute;
					right: 30rpx;
					top: 40rpx;
					background: #2E80FE;
					width: 133rpx;
					height: 50rpx;
					border-radius: 25rpx;
					font-size: 24rpx;
					font-weight: bold;
					color: #FFFFFF;
					display: flex;
					justify-content: center;
					align-items: center;
				}
			}

		}
	}

	.headBox {
		background: #FFDE2C;
		font-size: 27rpx;
		font-weight: 500;
		color: #333333;
		line-height: 40rpx;
		display: flex;
		padding: 0rpx 30rpx 50rpx;

		.tit {
			font-size: 40rpx;
			margin: 70rpx 0 45rpx;
			font-weight: bold;
			color: #333333;
			line-height: 32rpx;
		}

		image {
			width: 364rpx;
			height: 308rpx;
		}
	}
</style>